package com.woniuxy.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.shop.entity.Address;
import com.woniuxy.shop.mapper.AddressMapper;
import com.woniuxy.shop.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author fanqiwen
 * @since 2023-02-07 11:56:01
 */
@Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, Address> implements AddressService {
    @Autowired
    AddressMapper addressMapper;
    @Override
    public void addAddress(String address, String tel, String name, Integer userId) {
        Address addressDo=new Address();
        addressDo.setAddress(address);
        addressDo.setName(name);
        addressDo.setTel(tel);
        addressDo.setUserId(userId);
        addressMapper.insert(addressDo);
    }

    @Override
    public List<Address> getAddressList(Integer userId) {
        QueryWrapper<Address> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("user_id",userId);
        return addressMapper.selectList(queryWrapper);
    }
}
